home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / stk100.zip / SPRTEST.C < prev    next >
C/C++ Source or Header  |  1990-10-20  |  3KB  |  86 lines

  1. /**********************************************************************
  2. * sprtest.c
  3. * A simple STK test program.
  4. * Compile with the command line "tcc sprtest.c stks.lib graphics.lib"
  5. * or use the integrated environment with the project file SPRTEST.PRJ.
  6. *
  7. **********************************************************************
  8.                     This file is part of
  9.  
  10.           STK -- The sprite toolkit -- version 1.0
  11.  
  12.               Copyright (C) Jari Karjala 1990
  13.  
  14. The sprite toolkit (STK) is a FreeWare toolkit for creating high
  15. resolution sprite graphics with PCompatible hardware. This toolkit 
  16. is provided as is without any warranty or such thing. See the file
  17. COPYING for further information. 
  18.  
  19. **********************************************************************/
  20.  
  21. #include <stdio.h>          /*** puts() ***/
  22. #include "stk.h"            /*** The Sprite Toolkit prototypes ***/
  23. #include "sprtest.smp"      /*** The sprite map to use **/
  24.  
  25. int main(int argc, char **argv)
  26. {
  27.     int i,j,k;
  28.     ANIM_SPRITE as1, as2;
  29.  
  30.     /**** Detect a suitable graphics mode, start it and init spr module ****/
  31.     gr_detect(GR_TYPE_SPR, &i, &j);
  32.     if (i == -1) {
  33.         puts("Unsupported graphics mode, need EGA or Hercules!");
  34.         return 1;
  35.     }
  36.     gr_start(&i, &j);
  37.     spr_initialize(i);
  38.  
  39.     /**** Create two animated sprites ****/
  40.     as1 = spr_anim_create(1, spr_create(sprtest_width, sprtest_height, 
  41.                                         sprtest_shape, sprtest_mask, 
  42.                                         8, 0));
  43.  
  44.     as2 = spr_anim_create(1, spr_create(sprtest_width, sprtest_height, 
  45.                                         sprtest_shape, sprtest_mask, 
  46.                                         8, 0));
  47.     if (as1==NULL || as2==NULL) {
  48.         gr_puts("Cannot create sprites.\nPress enter to exit");
  49.         while (gr_inkey()!=13)
  50.             ;
  51.         return 2;
  52.     }
  53.  
  54.     /**** Set sprite 1 properties *****/
  55.     spr_anim_set_time(as1, 0, 6, 5000);  /** Timeout after 5000 steps **/
  56.     spr_anim_set_location(as1, 20,15);      /** Initial position **/
  57.     spr_anim_set_limits(as1, 0,0, 400, gr_max_y);     /** Limits **/
  58.     spr_anim_set_vector(as1, 2,1);          /** Direction vector **/
  59.     spr_anim_start(as1);                    /** Activate the sprite **/
  60.     /**** Set sprite 2 properties *****/
  61.     spr_anim_set_time(as2, 0, 6, 5000); /** Timeout after 5000 steps **/
  62.     spr_anim_set_location(as2, 20,300);     /** Initial position **/
  63.     spr_anim_set_vector(as2, -2,2);         /** Direction vector **/
  64.     spr_anim_start(as2);                    /** Activate the sprite **/
  65.  
  66.     gr_dual_xy_printf(60,60,"***** HERE IS SOME BACKGROUND TEXTURE *****");
  67.     gr_dual_xy_printf(200,200,"***** HERE IS SOME BACKGROUND TEXTURE *****");
  68.     gr_dual_xy_printf(130,130,"Press Esc to exit");    
  69.     
  70.     k = 0;
  71.     do {    /**** Loop until the user presses the Esc key ****/
  72.         gr_dual_xy_printf(0,0,"Pass %d ",k);
  73.         spr_anim_next_pass();
  74.         spr_regulate_speed();
  75.         i = gr_inkey();
  76.         k++;
  77.     } while (i!=27);
  78.  
  79.     /**** No real need to use gr_end since it is bound with atexit() ****/
  80.     gr_end();
  81.     
  82.     return 0;
  83. }
  84.